/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ipo.mm.web.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.ipo.mm.web.util.ConstantManager;
import org.ipo.mm.web.util.pager.AbstractPager;
import org.ipo.mm.web.util.pager.LogPager;

/**
 *
 * @author makcro
 */
public class LogSearchAction extends org.apache.struts.action.Action {
    
   
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
            AbstractPager pager = null;

            String pageNumber = request.getParameter("p");
            if(pageNumber == null){

                pager = new LogPager();

                request.getSession().setAttribute(ConstantManager.SESSION_LOG_PAGER, pager);


            }

            else {
                pager = (AbstractPager) request.getSession().getAttribute(ConstantManager.SESSION_LOG_PAGER);
                pager.setPageNumber(Integer.parseInt(pageNumber));
            }

            pager.doPaging(request);

            ActionForward forward = mapping.findForward(ConstantManager.NAVIGATION_LOG_LIST);
            return forward;

    }
}
